package com.txby.dplus.identify;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import com.txby.dplus.common.annomapper.MybatisBaseDaoCRUD;
import com.txby.dplus.common.utils.util.IdWorker;
import com.txby.dplus.core.util.QuartzFactoryUtil;
import com.txby.dplus.identify.job.UploadDataJobTask;
import com.txby.dplus.identify.util.ConfigUtil;

@Component
@Order(value = 1)
public class CusApplicationRunner implements ApplicationRunner {
    @Resource(name = "mybatisBaseDaoCRUD")
    public MybatisBaseDaoCRUD mBaseDao;
    @Autowired
    public ConfigUtil cu;

    @Override
    public void run(ApplicationArguments var1) throws Exception {
        //重启时加入任务线程处理，30分未支付取消
        Map map = new HashMap();
        map.put("mBaseDao", mBaseDao);
        map.put("uploadUrl", cu.getUploadUrl());
        map.put("cu", cu);
        String sql = "select * from userunit";
/*        Map map1 = (Map) mBaseDao.findBySqlUniqueObject(sql, Map.class, null);
        if (null == map1.get("SN") || map1.get("SN").toString().isEmpty()) {
            sql = "update userunit set SN='td" + IdWorker.get51UUID() + "'";
            mBaseDao.executeSql(sql, null);
        }*/
        if(cu.getUploadIntSeconds()>0){
        	
        	System.out.println("-------------添加定时数据上传任务---------------");
        	QuartzFactoryUtil.getInstance().addJobByCalendar(UploadDataJobTask.defaultJobName, UploadDataJobTask.defaultJobName, UploadDataJobTask.class, cu.getUploadIntSeconds(), map);
        }
//        //？重启时加入任务线程处理，（已支付）21天自动确认收货，更新状态
//        QuartzFactoryUtil.getInstance().addJobByCalendar(StartUpConfirmOrderJobTask.defaultJobName,StartUpConfirmOrderJobTask.defaultJobName, StartUpConfirmOrderJobTask.class,1, map);
//        //？重启时加入任务线程处理，(已完成、已确认收货 ）30天自动关闭订单建议
//        QuartzFactoryUtil.getInstance().addJobByCalendar(StartUpCloseOrderJobTask.defaultJobName,StartUpCloseOrderJobTask.defaultJobName, StartUpCloseOrderJobTask.class,1, map);


    }


}